SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetQuestionnaire]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetQuestionnaire]
GO

/***************************************************************************
* Name:			GetQuestionnaire
* Purpose:		Returns the questionnaire with the specified id
*
* PARAMETERS
* Name			Description					
* -------------		-----------------------------------------------------------
* @id			id of the questionnaire
***************************************************************************/
CREATE PROCEDURE [dbo].[GetQuestionnaire](
	@id INT
)
AS

BEGIN

	Select [ID], [Name], [Description], Type, (Select RefMeaning from RefCode where RefCode = type) as TypeMeaning, Category, 
		(Select RefMeaning from RefCode where RefCode = category) as CategoryMeaning, CategorySequenceNo, AllowMultiple, ModuleType
	FROM Questionnaire
	WHERE [ID] = @id

END

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

